package com.scs.controller;

import com.alibaba.fastjson.JSONObject;
import com.scs.pojo.*;
import com.scs.service.TaskService;
import com.scs.service.UploadTaskService;
import com.scs.service.studentService;
import com.scs.utils.FileDownload;
import com.scs.utils.JsonDataUtils;
import com.alibaba.fastjson.JSON;
import com.scs.utils.fileDeleteUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.*;
import java.net.URL;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

@Controller()
@RequestMapping(value = "/Task")
public class taskController {
    @Autowired
    private TaskService taskService;
    @Autowired
    private UploadTaskService uploadTaskService;
    @Autowired
    private studentService studentService;


    @ResponseBody
    @RequestMapping(value = "/TeacherReleaseTask", produces = "application/json;charset=utf-8")
    //教师发布作业
    public String TeacherReleaseTask(HttpServletRequest request, MultipartFile[] file) {
        JSONObject data = new JSONObject();
        String teacherId = (String) request.getSession().getAttribute("userInformation");
        String role = (String) request.getSession().getAttribute("role");
        if(!role.equals("1")){
            data.put("msg", "用户权限不足");
            data.put("success", 0);
            return data.toJSONString();
        }
        if (teacherId == null || teacherId.equals("")) {
            data.put("msg", "未获取到用户信息");
            data.put("success", 0);
            return data.toJSONString();
        }
        String courseName = request.getParameter("courseName");
        String taskName = request.getParameter("taskName");
        String classes = request.getParameter("classes");
        String path = request.getSession().getServletContext().getRealPath("");
        String savePath = path.substring(0, path.indexOf("target\\response\\")) + "src\\releaseTask\\" +
                classes + "\\" + courseName + "\\"+taskName+"\\";
        String taskId = UUID.randomUUID().toString().replace("-", "").toUpperCase(Locale.ROOT);
        String taskClaim = request.getParameter("taskClaim");
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        String releaseTime = df.format(new Date());
        String deadTime = request.getParameter("deadTime");
        File fileDir = new File(savePath);//判断是否存在目录
        if (!fileDir.exists()) {//判断是否存在目录
            fileDir.mkdirs();
        }
        if (file != null) {
            for (MultipartFile File : file) {
                if (!File.isEmpty()) {
                    try {
                        String fileName = File.getOriginalFilename();
                        String Path = savePath + fileName;//创建储存
                        File.transferTo(new File(Path));
                        String filepath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/releaseTask/" +
                                classes + "/" + courseName + "/" +taskName+"/"+fileName;//服务器映射地址
                        ReleaseTask releaseTask = new ReleaseTask(taskId, teacherId, courseName, classes, taskName,
                                fileName, filepath, taskClaim, releaseTime, deadTime);
                        System.out.println(releaseTask);
                        taskService.releaseTaskInsert(releaseTask);//储存进数据库
                    } catch (Exception e) {
                        data.put("msg", "作业布置失败");
                        data.put("success", 0);
                        return data.toJSONString();
                    }
                }
            }
        } else {
            ReleaseTask releaseTask = new ReleaseTask(taskId, teacherId, courseName, classes, taskName,
                    null, null, taskClaim, releaseTime, deadTime);
            int count = taskService.releaseTaskInsert(releaseTask);
            if (count == 0) {
                data.put("msg", "作业布置失败");
                data.put("success", 0);
                return data.toJSONString();
            }
        }
        List<student> students = studentService.getStudentByClasses(classes);
        List<UploadTask> uploadTasks = new ArrayList<UploadTask>();
        for (student item : students) {
            String uploadTaskId = UUID.randomUUID().toString().replace("-", "").toUpperCase(Locale.ROOT);
            String score = "0";
            String status = "false";
            String checkStatus = "false";
            UploadTask uploadTask = new UploadTask(uploadTaskId, taskId, item.getUserId(),
                    item.getRealName(), courseName, classes, taskName, "null", "null", "null", score, status, checkStatus, "null");
            uploadTasks.add(uploadTask);
        }
        int count = uploadTaskService.uploadTaskInsert(uploadTasks);
        data.put("msg", "作业布置成功");
        data.put("success", 1);
        return data.toJSONString();
    }

    //学生下载作业
    @ResponseBody()
    @RequestMapping(value = "studentDownloadTask", produces = "application/json;charset=utf-8")
    public String studentDownloadTask(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        JSONObject data = new JSONObject();
        String taskName = request.getParameter("taskName");
        List<File> files = new ArrayList<File>();
        List<String> filePathList = Collections.singletonList(request.getParameter("filePathList"));
        if (filePathList != null) {
            for (String filePath : filePathList) {
                File file = new File(filePath);
                files.add(file);
            }
        } else {
            data.put("msg", "未获取取到正确路径");
            data.put("success", 0);
        }

        String fileName = taskName + ".zip";
        // 在服务器端创建打包下载的临时文件
        String outFilePath = request.getSession().getServletContext().getRealPath("/") + "download/";
        File dirFile = new File(outFilePath);//先创建存放压缩包的目录
        if (!dirFile.exists()) {//判断是否存在目录
            dirFile.mkdirs();
        }
        File fileZip = new File(outFilePath + fileName);
        System.out.println(fileZip);
        System.out.println("_______________________________________________________________________________");
        // 文件输出流
        FileOutputStream outStream = new FileOutputStream(fileZip);
        // 压缩流
        ZipOutputStream toClient = new ZipOutputStream(outStream);
        //  toClient.setEncoding("gbk");
        FileDownload fileDownload = new FileDownload();
        fileDownload.zipFile(files, toClient);
        toClient.close();
        outStream.close();
        fileDownload.downloadFile(fileZip, response, true);
        data.put("msg", "文件下载成功");
        data.put("success", 1);
        return data.toJSONString();

    }


    @ResponseBody
    @RequestMapping(value = "isItTimeOut", produces = "application/json;charset=utf-8")
    //判断是否超时
    public String isItTimeOut(HttpServletRequest request) throws Exception {
        JSONObject data = new JSONObject();
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        long uploadTime = new Date().getTime();
        String courseName = request.getParameter("courseName");
        String classes = request.getParameter("classes");
//        List<student> student = (List<com.scs.pojo.student>) request.getSession().getAttribute("userInformation");
//        if(student==null){
//            data.put("msg","为获取到用户信息");
//            data.put("success",0);
//        }
//        String classes = student.get(0).getClasses();
        String taskName = request.getParameter("taskName");
        List<ReleaseTask> tasks = taskService.studentSelectTask(courseName, classes, taskName);
        long deadTime = df.parse(tasks.get(0).getDeadTime()).getTime();//获取截止日期的时间戳
        if (uploadTime > deadTime) {
            data.put("msg", "已超时无法提交作业");
            data.put("status", 0);
            data.put("success", 0);
        } else {
            data.put("msg", "未超时可以提交作业");
            data.put("status", 1);
            data.put("success", 1);
        }
        return data.toJSONString();
    }

    @ResponseBody
    @RequestMapping(value = "/getTaskById", produces = "application/json;charset=utf-8")
    //通过Id获取作业
    public String getTaskById(HttpServletRequest request) throws Exception {
        JSONObject data = new JSONObject();
        String taskId = request.getParameter("taskId");
        if (taskId == null || taskId.equals("")) {
            data.put("msg", "作业ID参数无效");
            data.put("success", 0);
            data.put("data", "");
        } else {
            List<ReleaseTaskChild> tasks = taskService.getTaskById(taskId);
            data.put("msg", "查询作业信息成功");
            data.put("success", 1);
            data.put("data", tasks);
        }
        return data.toJSONString();
    }

    @ResponseBody
    @RequestMapping(value = "studentUploadTask", produces = "application/json;charset=utf-8")
    //学生上传作业
    public String studentUploadTask(HttpServletRequest request, MultipartFile[] file) throws ParseException {
        JSONObject data = new JSONObject();
        String userId = (String) request.getSession().getAttribute("userInformation");
        if(userId == null || userId.equals("")){
            data.put("msg", "未获取到用户信息");
            data.put("success", 0);
            return data.toJSONString();

        }
        String uploadClaim = request.getParameter("uploadClaim");
        if (file == null || uploadClaim == null) {
            data.put("msg", "请提交作业信息");
            data.put("success", 0);
            return data.toJSONString();
        }
        String TaskId = request.getParameter("taskId");
        String classes = request.getParameter("classes");
        String taskName = request.getParameter("taskName");
        String courseName = request.getParameter("courseName");
        String path = request.getSession().getServletContext().getRealPath("");
        String savePath = path.substring(0, path.indexOf("target\\response\\")) + "src\\uploadTask\\" +
                "\\" + classes + "\\" + courseName + "\\" + taskName +"\\";
        List<UploadTask> uploadTask = uploadTaskService.searchOfTaskSubmit(TaskId,userId);
        if(uploadTask.get(0).getFileName()!="null"){
            File file1 = new File(savePath+uploadTask.get(0).getFileName());
            boolean delete = file1.delete();
            if(delete == false){
                data.put("msg", "作业文件删除失败");
                data.put("success", 0);
                return data.toJSONString();
            }
        }


        List<ReleaseTaskChild>  releaseTaskChildren = taskService.getTaskById(TaskId);
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        long uploadTime = new Date().getTime();
        long deadTime = df.parse(releaseTaskChildren.get(0).getDeadTime()).getTime();//获取截止日期的时间戳
        if (uploadTime > deadTime) {
            data.put("msg", "已超时无法提交作业");
            data.put("status", 0);
            data.put("success", 0);
        } else {

            File fileDir = new File(savePath);//判断是否存在目录
            if (!fileDir.exists()) {//判断是否存在目录
                fileDir.mkdirs();
            }
            if (file != null) {
                for (MultipartFile File : file) {
                    if (!File.isEmpty()) {
                        try {
                            String fileName = userId+"-"+File.getOriginalFilename();
                            String Path = savePath + fileName;//创建储存上传文件的路径
                            File.transferTo(new File(Path));
                            String status = "true";
                            String filepath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/uploadTask/" +
                                    classes + "/" + courseName + "/" + taskName +"/"+fileName;
                            int count = uploadTaskService.uploadTaskUpdate(userId, TaskId, filepath, fileName, status, uploadClaim);
                            if (count == 0) {
                                data.put("msg", "作业上传失败失败");
                                data.put("success", 0);
                                return data.toJSONString();
                            }
                        } catch (Exception e) {
                            data.put("msg", "作业上传失败失败");
                            data.put("success", 0);
                            return data.toJSONString();
                        }
                    }
                }
            } else {
                String status = "true";
                int count = uploadTaskService.uploadTaskUpdate(userId, TaskId, "null", "null", status, uploadClaim);
                if (count == 0) {
                    data.put("msg", "作业上传失败失败");
                    data.put("success", 0);
                    return data.toJSONString();
                }
            }
            data.put("msg", "作业上传成功");
            data.put("success", 1);
        }
        return data.toJSONString();
    }

    @ResponseBody
    @RequestMapping(value = "teacherDownloadStudentTask", produces = "application/json;charset=utf-8")
    //教师下载作业
    public String teacherDownloadStudentTask(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        JSONObject data = new JSONObject();
        String teacherId = (String) request.getSession().getAttribute("userInformation");
        String role = (String) request.getSession().getAttribute("role");
        if(!role.equals("1")){
            data.put("msg", "用户权限不足");
            data.put("success", 0);
            return data.toJSONString();
        }
        if (teacherId == null || teacherId.equals("")) {
            data.put("msg", "未获取到用户信息");
            data.put("success", 0);
            return data.toJSONString();
        }
        String taskId = request.getParameter("taskId");
        String courseName = request.getParameter("courseName");
        String classes = request.getParameter("classes");
        String taskName = request.getParameter("taskName");
        List<UploadTask> uploadTasks = uploadTaskService.getStudentsTaskByTaskId(taskId);
        List<String> filePathList = new ArrayList<>();
        for(UploadTask item : uploadTasks){
            if(item.getUploadFilePath().equals("null") || item.getUploadFilePath()==null){
                continue;
            }else{
                String  subPath = item.getUploadFilePath().substring(item.getUploadFilePath().lastIndexOf("uploadTask"));
                System.out.println(subPath);
                subPath.replace("/","\\");
                filePathList.add(subPath);

            }
        }
        String path = request.getSession().getServletContext().getRealPath("");
        String savePath = path.substring(0, path.indexOf("target\\response\\")) + "src\\";
        System.out.println(savePath);
        System.out.println(filePathList);
        List<File> files = new ArrayList<File>();

        if (filePathList.size()!= 0) {
            for (String item : filePathList) {
                String filePath=savePath+item;
                System.out.println(filePath);
                File file = new File(filePath);
                files.add(file);
            }
        } else {
            data.put("msg", "未获取取到正确路径");
            data.put("success", 0);
            return data.toJSONString();
        }
        String fileName = courseName + classes + taskName + ".zip";
        // 在服务器端创建打包下载的临时文件
        String outFilePath = request.getSession().getServletContext().getRealPath("/") + "download/";
        File dirFile = new File(outFilePath);//先创建存放压缩包的目录
        if (!dirFile.exists()) {//判断是否存在目录
            dirFile.mkdirs();
        }
        File fileZip = new File(outFilePath + fileName);
        System.out.println(fileZip);
        System.out.println("_______________________________________________________________________________");
        // 文件输出流
        FileOutputStream outStream = new FileOutputStream(fileZip);
        // 压缩流
        ZipOutputStream toClient = new ZipOutputStream(outStream);
        //  toClient.setEncoding("gbk");
        FileDownload fileDownload = new FileDownload();
        fileDownload.zipFile(files, toClient);
        toClient.close();
        outStream.close();
        fileDownload.downloadFile(fileZip, response, true);
        data.put("msg", "文件下载成功");
        data.put("success", 1);
        return data.toJSONString();
    }

    @ResponseBody
    @RequestMapping(value = "getTaskNameByCourseNameAndClasses", produces = "application/json;charset=utf-8")
    //通过课程和班级获取作业名
    public String getTaskNameByCourseNameAndClasses(HttpServletRequest request) {
        JSONObject data = new JSONObject();
//        List<student> student = (List<com.scs.pojo.student>) request.getSession().getAttribute("userInformation");
//        if(student==null){
//            data.put("msg","为获取到用户信息");
//            data.put("success",0);
//            return data.toJSONString();
//        }
//        String classes =  student.get(0).getClasses();
        String classes = request.getParameter("classes");
        String courseName = request.getParameter("courseName");
        List<String> taskNameList = taskService.getTaskNameByCourseNameAndClasses(classes, courseName);
        System.out.println(taskNameList);
        if (taskNameList.size() == 0) {
            data.put("msg", "为获取到作业信息");
            data.put("success", 0);
        } else {
            data.put("msg", "获取到信息");
            data.put("success", 1);
            data.put("data", taskNameList);
        }
        return data.toJSONString();
    }


    @ResponseBody
    @RequestMapping(value = "teacherGetTask", produces = "application/json;charset=utf-8")
    //通过教师Id获取该教师布置的作业
    public String teacherGetTask(HttpServletRequest request) throws ParseException, UnsupportedEncodingException {
        JSONObject data = new JSONObject();
        String teacherId = (String) request.getSession().getAttribute("userInformation");
        if (teacherId == null || teacherId.equals("")) {
            data.put("msg", "未获取到用户信息");
            data.put("data", "");
            data.put("count", "0");
            data.put("code", 110);
            return data.toJSONString();
        }
        List<ReleaseTaskChild> releaseTasks = taskService.teacherGetTask(teacherId);
        String HomeworkStatus = "";
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        long nowTime = new Date().getTime();
        for (ReleaseTaskChild item : releaseTasks) {
            if (item.getDeadTime() == null) {
                HomeworkStatus = "100";
                item.setStatus(HomeworkStatus);
                continue;
            }
            long deadTime = df.parse(item.getDeadTime()).getTime();//获取截止日期的时间戳
            if (nowTime > deadTime) {
                HomeworkStatus = "110";
            } else {
                HomeworkStatus = "100";
            }
            item.setStatus(HomeworkStatus);
        }
        if (releaseTasks.size() == 0) {
            data.put("msg", "未查询到该教师布置的作业");
            data.put("data", "");
            data.put("count", 0);
            data.put("code", 110);
        } else {
            data.put("msg", "查询成功");
            data.put("data", releaseTasks);
            data.put("count", releaseTasks.size());
            data.put("code", 0);
        }
        return data.toJSONString();
    }


    @ResponseBody
    @RequestMapping(value = "getStudentsTaskByTaskId", produces = "application/json;charset=utf-8")
    //通过作业Id获取该班级所有人的作业
    public String getStudentsTaskByTaskId(HttpServletRequest request) {
        JSONObject data = new JSONObject();
        String teacherId = (String) request.getSession().getAttribute("userInformation");
        String taskId = request.getParameter("taskId");
        if (teacherId == null || teacherId.equals("")) {
            data.put("msg", "未获取到用户信息");
            data.put("data", "");
            data.put("count", 0);
            data.put("code", 110);
        } else if (taskId == null || taskId.equals("")) {
            data.put("msg", "作业参数传递错误");
            data.put("data", "");
            data.put("count", 0);
            data.put("code", 110);
        } else {
            List<UploadTask> uploadTasks = uploadTaskService.getStudentsTaskByTaskId(taskId);
            if (uploadTasks.size() == 0) {
                data.put("msg", "暂无学生完成情况");
                data.put("data", "");
                data.put("count", 0);
                data.put("code", 110);
            } else {
                data.put("msg", "作业完成情况查询成功");
                data.put("data", uploadTasks);
                data.put("count", uploadTasks.size());
                data.put("code", 0);
            }

        }
        return data.toJSONString();
    }

    @ResponseBody
    @RequestMapping(value = "studentGetTask", produces = "application/json;charset=utf-8")
    //学生查看作业，并返回时间以及批改状态
    public String studentGetTask(HttpServletRequest request) throws ParseException, UnsupportedEncodingException {
        JSONObject data = new JSONObject();
        List<student> students = (List<student>) request.getSession().getAttribute("userData");
        if (students.size() == 0) {
            data.put("msg", "未获取到用户信息");
            data.put("data", "");
            data.put("count", 0);
            data.put("code", 110);
        } else {
            String classes = students.get(0).getClasses();
            String userId = students.get(0).getUserId();
            String HomeworkStatus = "";
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
            long nowTime = new Date().getTime();
            List<ReleaseTaskChild> releaseTasks = taskService.studentGetTask(classes,userId);
            if (releaseTasks.size() == 0) {
                data.put("msg", "未查询到作业信息");
                data.put("data", "");
                data.put("count", 0);
                data.put("code", 110);
            } else {
                for (ReleaseTaskChild item : releaseTasks) {
                    if (item.getDeadTime() == null) {
                        HomeworkStatus = "100";//超时
                        item.setStatus(HomeworkStatus);
                        continue;
                    }
                    long deadTime = df.parse(item.getDeadTime()).getTime();//获取截止日期的时间戳
                    if (nowTime > deadTime) {
                        HomeworkStatus = "110";
                    } else {
                        HomeworkStatus = "100";
                    }
                    item.setStatus(HomeworkStatus);

                }
                data.put("msg", "获取作业成功");
                data.put("data", releaseTasks);
                data.put("count", releaseTasks.size());
                data.put("code", 0);
            }
        }
        return data.toJSONString();
    }

    @ResponseBody
    @RequestMapping(value = "/teacherDeleteTask",produces = "application/json;charset=utf-8")
    //教师删除作业
    public String teacherDeleteTask(HttpServletRequest request){
        JSONObject data = new JSONObject();
        String teacherId = (String) request.getSession().getAttribute("userInformation");
        List<String> taskId = Collections.singletonList(request.getParameter("taskId"));
        String courseName = request.getParameter("courseName");
        String classes = request.getParameter("classes");
        String taskName = request.getParameter("taskName");
        String path = request.getSession().getServletContext().getRealPath("");
        String releasePath = path.substring(0, path.indexOf("target\\response\\")) + "src\\releaseTask\\" +
                classes + "\\" + courseName + "\\"+taskName+"\\";
        String uploadPath = path.substring(0, path.indexOf("target\\response\\")) + "src\\uploadTask\\" +
                "\\" + classes + "\\" + courseName + "\\" + taskName +"\\";
        if (teacherId == null || teacherId.equals("")) {
            data.put("msg", "未获取到用户信息");
            data.put("success", 0);
        } else if (taskId == null || taskId.equals("")) {
            data.put("msg", "作业参数传递错误");
            data.put("success", 0);
        }else{
            File releaseFile = new File(releasePath);
            File uploadFile = new File(uploadPath);
            fileDeleteUtils fileDeleteUtils = new fileDeleteUtils();
            fileDeleteUtils.deleteDir(releaseFile);
            fileDeleteUtils.deleteDir(uploadFile);
            int deleteCount = taskService.teacherDeleteTask(taskId);
            int deleteUploadCount = uploadTaskService.teacherDeleteTask(taskId);
            if(deleteCount==0||deleteUploadCount==0){
                data.put("msg", "删除作业失败");
                data.put("success", 0);
            }
            data.put("msg", "删除作业成功");
            data.put("success", 1);
        }
        return data.toJSONString();
    }

    @ResponseBody
    @RequestMapping(value = "/searchOfTaskSubmit",produces = "application/json;charset=utf-8")
    //模糊查询学生作业
    public String searchOfTaskSubmit(HttpServletRequest request){
        JSONObject data = new JSONObject();
        String teacherId = (String) request.getSession().getAttribute("userInformation");
        String role = (String) request.getSession().getAttribute("role");
        if(!role.equals("1")){
            data.put("msg", "用户权限不足");
            data.put("code", 110);
            return data.toJSONString();
        }
        if (teacherId == null || teacherId.equals("")) {
            data.put("msg", "未获取到用户信息");
            data.put("code", 110);
            return data.toJSONString();
        }
        String key = request.getParameter("key");
        String taskId = request.getParameter("taskId");
        List<UploadTask> uploadTasks = uploadTaskService.searchOfTaskSubmit(taskId,key);
        if(uploadTasks.size()==0){
            data.put("msg","未查询到学生作业");
            data.put("data","");
            data.put("count",0);
            data.put("code",110);
        }
        data.put("msg","查询学生作业成功");
        data.put("data",uploadTasks);
        data.put("count",uploadTasks.size());
        data.put("code",0);
        return data.toJSONString();
    }

    @ResponseBody
    @RequestMapping(value = "teacherCorrectUploadTask",produces = "application/json;charset=utf-8")
    //教师批改失败
    public String teacherCorrectUploadTask(HttpServletRequest request){
        JSONObject data = new JSONObject();
        String teacherId = (String) request.getSession().getAttribute("userInformation");
        String role = (String) request.getSession().getAttribute("role");
        if(!role.equals("1")){
            data.put("msg", "用户权限不足");
            data.put("success", 0);
            return data.toJSONString();
        }
        if (teacherId == null || teacherId.equals("")) {
            data.put("msg", "未获取到用户信息");
            data.put("success", 0);
            return data.toJSONString();
        }
        String userId = request.getParameter("userId");
        String taskId = request.getParameter("taskId");
        String score = request.getParameter("score");
        String teacherComment = request.getParameter("teacherComment");
        String checkStatus = "true";
        int count = uploadTaskService.teacherCorrectUploadTask(userId,taskId,score,teacherComment,checkStatus);
        if(count==0){
            data.put("msg", "提交批改信息失败");
            data.put("success", 0);
        }
        data.put("msg", "提交批改信息成功");
        data.put("success", 1);
        return data.toJSONString();
    }
}
